class ExceptionMessage {
	constructor({
		status = true,
		message,
		loading = true
	}) {
		this.status = status;
		this.message = message;
		this.loading = loading;
	}
}

export const exception = (target, name, descriptor) => {
	const oldValue = descriptor.value;
	descriptor.value = async function() {
		try {
			// this.NProgress.start();
			await oldValue.apply(this, arguments);
		} catch (err) {
			/* eslint-disable */
			!err.status && console.log(name, err);
			err = new ExceptionMessage(err);
			// err.status && this.$message({ type: 'error', message: err.message });
			// err.status && this.$notify.error({
			//     title: err.message,
			//     showClose: false,
			//     duration: 2500
			// });
			// typeof err.loading === 'boolean' && err.loading && (this.loading = false);
			uni.showToast({
				icon: 'none',
				title: err.message || '操作失败'
			})
			this.btnload = false;
			this.loading = false;
		} finally {
			// this.NProgress.done();
		}
	};
	return descriptor;
};